//
//  CentRedBagTableViewCell.m
//  智积分
//
//  Created by Cynic on 2018/7/18.
//  Copyright © 2018年 Cynic. All rights reserved.
//

#import "CentRedBagTableViewCell.h"

@implementation CentRedBagTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    /*@property (nonatomic ,retain)UILabel *title;
     @property (nonatomic ,retain)UITextField *field;
     @property (nonatomic ,retain)UITextView *infoView;
     @property (nonatomic ,retain)UILabel *notice;*/
    
//    UIView *bgView = [[UIView alloc] initWithFrame:CGRectZero];
//    bgView.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.5];
//    [self.contentView addSubview:bgView];
//    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(15);
//        make.right.mas_equalTo(-15);
//        make.top.mas_equalTo(0);
//        make.bottom.mas_equalTo(0);
//    }];
    
    UIView *layerView = [[UIView alloc] initWithFrame:CGRectZero];
    layerView.backgroundColor = [UIColor whiteColor];
//    layerView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    layerView.layer.cornerRadius = 5;
    [self.contentView addSubview:layerView];
    [layerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(10);
//        make.height.mas_equalTo(55);
        make.bottom.mas_equalTo(-45);
//        make.bottom.mas_equalTo(0);
//        make.bottom.mas_equalTo(-10);
    }];
    
    _title = [[UILabel alloc] initWithFrame:CGRectZero];
    _title.font = [UIFont systemFontOfSize:14];
    _title.textColor = [UIColor blackColor];
    [layerView addSubview:_title];
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(15);
//        make.height.mas_equalTo();
    }];
    
//    _field = [[UITextField alloc] initWithFrame:CGRectZero];
//    _field.font = [UIFont systemFontOfSize:14];
//    _field.textColor = [UIColor ColorWithHex:@"666666" withAlpha:1];
//    _field.userInteractionEnabled = NO;
//    _field.textAlignment = NSTextAlignmentRight;
//    [layerView addSubview:_field];
//    [_field mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(-15);
//        make.top.mas_equalTo(15);
//        make.centerY.mas_equalTo(0);
//    }];
    
    
    WEAKSELF;
    _infoView = [[UITextView alloc] initWithFrame:CGRectZero];
    _infoView.textColor = [UIColor ColorWithHex:@"666666" withAlpha:1];
    
    _infoView.scrollEnabled = NO;
    _infoView.clipsToBounds = YES;
    _infoView.font = [UIFont systemFontOfSize:14];
    [_infoView loadplaceholder];
    _infoView.max = 100;
    [layerView addSubview:_infoView];
    [_infoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(weakSelf.title.mas_bottom).mas_offset(10);
        make.bottom.mas_equalTo(-10);
    }];
    
    
//    [_infoView cx_eventsChangeByHandler:^{
//        NSLog(@"new infoview text = %@",_infoView.text);
////        [UIView performWithoutAnimation:^{
////            [weakSelf.MainView beginUpdates];
////            [weakSelf.MainView endUpdates];
////        }];
//    }];
    
    _notice = [[UILabel alloc] initWithFrame:CGRectZero];
    _notice.font = [UIFont systemFontOfSize:14];
    _notice.textColor = [UIColor ColorWithHex:@"9B9B9B" withAlpha:1];
    _notice.numberOfLines = 0;
    [self.contentView addSubview:_notice];
    [_notice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
//        make.top.mas_equalTo(layerView.mas_bottom).mas_offset(7.5);
        make.bottom.mas_equalTo(-20);
    }];
    
    
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
